const state = {
    tabs: [],
    activeIndex: "",
}

const mutations = {
    add_tabs(state, data) {
        this.state.openTab.push(data);
      },
      remove_tabs(state, route) {
        let index = 0;
        for (let gohh of state.openTab) {
          if (gohh.route === route) {
            break;
          }
          index++;
        }
        this.state.openTab.splice(index, 1);
      },
      active_tab(state, index) {
        this.state.activeIndex = index;
      },
}

const actions = {
    add_tabs({ commit }, data) {
    commit('add_tabs', data)
  },
  remove_tabs({ commit }, route) {
    commit('add_tabs', route)
  },
  active_tab({ commit }, index) {
    commit('add_tabs', route)
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}


